import { mainRouter } from "../router/index";
// 课程分类
export const categoryData = (data) => {
  const courseData = data.filter((item) => item.parent == "0-0");
  courseData.forEach((item) => {
    const children = data.filter((child) => item.name == child.parent);
    if (children.length) {
      item.children = children;
    }
  });
  return courseData;
};

// 路由键值对
export const routerKVP = () => {
  let arrData = {};
  function loop(arr) {
    arr.forEach((item) => {
      if (item.children) {
        loop(item.children);
      }
      arrData[item.key] = item.label;
    });
  }
  loop(mainRouter);
  return arrData;
};
